
**** Returns to Scale from Labor Specialization: Evidence from Asset Management Mergers (Luo, Manconi and Schumacher) *************
*Purpose: Generate Table 1A, 1B and 10

**Define macros 
global controls "firmsize fundsize volatility expenses pastreturn" 


**-------------------Table 1, Panel A -------------------**
clear all
use "$datapath\statistics_firmlevel.dta"

 ** Column 1
estpost tabstat noofmgrs noofstyles nooffunds totalsize if factsetsample == 0, stat(mean) col(stat) 
eststo stat
esttab stat using "$outputpath/Table1A_1C.rtf", replace ///
nolines label nomtitle nonumber nonote noobs ///
cells(" mean(fmt(%9.2fc)) ") collabels(none) 

 ** Columns 2 and 3 
foreach n in 1 0{
estpost tabstat noofmgrs noofstyles nooffunds totalsize if largedelta == `n' & factsetsample == 0, stat(mean) col(stat) 
eststo stat
esttab stat using "$outputpath/Table1A_1C.rtf", append ///
nolines label nomtitle nonumber nonote noobs ///
cells(" mean(fmt(%9.2fc)) ") collabels(none) 
}

 ** Column 4
estpost tabstat noofmgrs noofstyles nooffunds totalsize if factsetsample == 1, stat(mean) col(stat) 
eststo stat
esttab stat using "$outputpath/Table1A_1C.rtf", append ///
nolines label nomtitle nonumber nonote noobs ///
cells(" mean(fmt(%9.2fc)) ") collabels(none) 


**-------------------Table 1, Panel B -------------------**
keep if factsetsample == 0
gen target = 1-bidder

foreach deal in 1 0 {
	
qui foreach m of varlist noofmgrs noofstyles nooffunds totalsize pastreturn crossfundstd{

** Columns 1 and 2, 5 and 6
 reg `m' bidder target if largedelta == `deal' , noc cluster(deal_id)
estimates store `m'
scalar define t0_`m' = _b[target]
scalar define t1_`m' = _b[bidder]

** Columns 3 and 4, 7 and 8
 reg `m' bidder if largedelta == `deal', cluster(deal_id)
estimates store `m'
scalar define dif_`m' = _b[bidder]
scalar define t_`m' = _b[bidder]/_se[bidder]
}

log using "$outputpath/Table1B.log", append
foreach m of varlist noofmgrs noofstyles nooffunds totalsize pastreturn crossfundstd{
disp as text " `m' " as result %7.2f t1_`m' ///
as text "    " as result %7.2f t0_`m' ///
as text "    " as result %7.2f dif_`m' ///
as text "    " as result %7.2f t_`m'
}
log close
}


**-------------------Table 10-------------------**
clear all
use "$datapath\acquiror_target_matching.dta"

qui foreach n of numlist 10 15 20 25{
 reghdfe realtarget differentdistribution styledistance sizedifference geographicaldistance differentlanguage performancedifference $controls if closeness <=`n', a(deal_id) cluster(deal_id time)
 estadd local deal Y 
estadd local ctrl Y
estimates store xs_`n'
}

esttab xs_10 xs_15 xs_20 xs_25 using "$outputpath/Table10.rtf", replace ///
keep(differentdistribution styledistance sizedifference geographicaldistance differentlanguage performancedifference) ///
order(differentdistribution styledistance sizedifference geographicaldistance differentlanguage performancedifference) ///
b(%5.3f) t(%5.2f) nolines noeqlines nolabel nogaps ///
stats(deal ctrl r2 N, fmt(0 0 3 %9.0gc)) ///
starlevels(* 0.10 ** 0.05 *** 0.01) nonotes varwidth(15) modelwidth(10) noomitted 